import './js/libs/weapp-adapter';
const ctx = canvas.getContext('2d');

// 导入背景绘制模块
import Background from './js/Background.js';
const bg = new Background(ctx);


// 导入英雄飞机
import Hero from './js/Hero.js';
const hero = new Hero(ctx);
hero.listen();

// //绘制敌机
// import Enemy from './js/Enemy.js'
// const enemy = new Enemy(ctx);

// 导入批量敌机生成模块
import Pool from './js/Pool.js';
const pool = new Pool(ctx);



// 动画效果控制
function gameStart() {
    // 控制动画逻辑
    // 清空画布
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    // 绘制背景效果
    bg.draw();

    // 绘制英雄飞机
    hero.draw();

    // 绘制敌机
    // enemy.draw();
    pool.drawEnemys();
    //绘制子弹
    pool.drawHeroBullet(hero);

    requestAnimationFrame(gameStart);
}

gameStart();